<template>
  <div class="area">
    <div class="bg">
      <div class="content">
        <div class="th">全国风险地区汇总</div>
        <template v-if="high_count> 0">
          <div class="title">
            <img src="../../assets/images/high.png" alt="" width="centern">
            高风险区{{ high_count }}个</div>
          <ul class="list">
            <li v-for="(item, index) in high" :key="index">
              <div v-for="(items,index1) in item.communitys" :key="index1">
                {{item.area_name+items}}
              </div>
            </li>
          </ul>
        </template>
        <!-- 中风险 -->
        <template v-if="mid_count > 0">
          <div class="title">
            <img src="../../assets/images/mid.png" alt="">
            中风险区{{ mid_count}}个</div>
          <ul class="list">
            <li v-for="(item, index) in mid" :key="index">
              <div v-for="(items,index1) in item.communitys" :key="index1">
                {{item.area_name+items}}
              </div>
            </li>
          </ul>
        </template>
      </div>
    </div>
  </div>
</template>

<script>
import api from '../../api/index'
export default {
  data() {
    return {
      high: [], // 高风险区数据
      high_count: 0,
      high_community: [],

      mid: [], // 低风险区域
      mid_count: 0,
      mid_community: []
    }
  },
  created() {
    api.getRiskCity().then(res => {
      console.log(res.data.data, '我是风险地区')
      // 高风险
      this.high_count = res.data.data.high_count
      this.high = res.data.data.high_list
      this.high_community = res.data.data.high_list.community
      // 中风险
      this.mid_count = res.data.data.middle_count
      this.mid = res.data.data.middle_list
      this.mid_community = res.data.data.middle_list.community
    })
  }
}
</script>

<style lang='less' scoped>
.area {
  background: rgb(113, 113, 232);
}
.bg {
  height: 3.6rem;
  background: url('../../assets/images/area.jpg') no-repeat;
  background-size: cover;
  padding-top: 2.6rem;
}
.content {
  background: #fff;
  margin-left: 0.2rem;
  margin-right: 0.2rem;
  padding: 0.2rem;
  border-radius: 0.2rem;
  min-height: 4rem;
  margin-bottom: 0.2rem;
  .th {
    margin-bottom: 0.3rem;
    font-size: 0.34rem;
  }
  .th:before {
    display: inline-block;
    width: 0.1rem;
    height: 0.3rem;
    margin-right: 0.1rem;
    background-color: #4169e2;
    content: '';
    vertical-align: middle;
  }
  .title {
    font-size: 0.3rem;
    margin-bottom: 0.3rem;
    img {
      width: 0.4rem;
      vertical-align: top;
    }
  }
  .list {
    li {
      margin-bottom: 0.2rem;
      color: #333;
      background: #f7f7f7;
      padding: 0.1rem;
      border-radius: 0.1rem;
      letter-spacing: 0.01rem;
      line-height: 0.5rem;
    }
  }
}
</style>
